import React from 'react'
export function Child1(props) {
  // props中的属性是只读的
  let { data, onChange } = props;
  const change = () => {
    onChange('hello')
  }
  return <div>
    Child1 {data}
    <button onClick={change}>按钮1</button>
  </div>
}

export class Child2 extends React.Component {
  change = () => {
    this.props.onChange("world")
  }
  render() {
    let { data, onChange } = this.props;
    return <div>
      child2 {data}
      <button onClick={this.change}>按钮1</button>
      <button onClick={onChange.bind(null, 'world2')}>按钮1</button>
    </div>
  }
}
